home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / Development / PowerD / Pdmod / modules / sys / time.m < prev    next >
Encoding:
Text File  |  2002-10-28  |  2.8 KB  |  105 lines

  1. /*
  2.  * $Id: time.h,v 1.14 1993/10/18 05:48:28 jraja Exp $
  3.  *
  4.  * Copyright (c) 1993 AmiTCP/IP Group, <amitcp-group@hut.fi>
  5.  *                    Helsinki University of Technology, Finland.
  6.  *                    All rights reserved.
  7.  *
  8.  */
  9.  
  10. MODULE 'devices/timer'
  11.  
  12.  
  13. /* 
  14.  * struct timeval is defined in <devices/timer.h>.  It is similar to the
  15.  * struct timeval defined normally in sys/time.h, but the names of the
  16.  * fields are different and the values are unsigned long instead of
  17.  * long. Following code rename the fields so that the UNIX code
  18.  * works correctly. (tv_sec and tv_usec are signed!!)
  19.  */
  20.  
  21. OBJECT compatible_timeval
  22.     [CUNION
  23.         s_sec:LONG,
  24.         u_secs:ULONG
  25.     ENDUNION]:mtv_sec,
  26.     [CUNION
  27.         s_usec:LONG,
  28.         u_micro:ULONG
  29.     ENDUNION]:mtv_usec
  30.  
  31. /*
  32. #define timeval compatible_timeval
  33. #define tv_sec mtv_sec.s_sec
  34. #define tv_usec mtv_usec.s_usec
  35. #define tv_secs mtv_sec.u_secs
  36. #define tv_micro mtv_usec.u_micro
  37. */
  38. /*
  39.  * We must define the timerequest, because compatible_timeval is not 
  40.  * compatible with old timeval...
  41.  */
  42. OBJECT compatible_timerequest
  43.     tr_node:IORequest,
  44.     tr_time:TimeVal
  45.  
  46. /*
  47. #define timerequest compatible_timerequest
  48. */
  49. /*
  50.  * predefine TimerBase to Library to follow SASC convention.
  51.  */
  52. /*
  53.  * The functionality and interface of get_time() and microtime() is similar
  54.  * to the amiga timer.device's GetSysTime(), so they are just defined as
  55.  * follows:
  56.  */
  57. #define get_time GetSysTime
  58. #define microtime GetSysTime
  59. /* 
  60.  * There are no timezones in V36 timer device, nor tries the KERNEL to 
  61.  * use them.
  62.  */
  63. #define gettimeofday(x,y) GetSysTime(x) 
  64. /*
  65.  * These are not used by AmiTCP/IP itself
  66.  */
  67.  
  68. /*
  69.  * bacause of a name conflict with SAS/C time.h definition 'timezone' and
  70.  * BSD sys/time.h struct timezone, time.h must always be included first.
  71.  * (the struct timezone becomes actually struct __timezone, but this does
  72.  * not raise a problem at the source level).
  73.  */
  74.  
  75. OBJECT timezone
  76.     tz_minuteswest:LONG, /* minutes west of Greenwich */
  77.     tz_dsttime:LONG     /* type of dst correction */
  78.  
  79. #define DST_NONE        0       /* not on dst */
  80. #define DST_USA         1       /* USA style dst */
  81. #define DST_AUST        2       /* Australian style dst */
  82. #define DST_WET         3       /* Western European dst */
  83. #define DST_MET         4       /* Middle European dst */
  84. #define DST_EET         5       /* Eastern European dst */
  85. #define DST_CAN         6       /* Canada */
  86.  
  87. /* defined in the net.lib */
  88. //extern int gettimeofday(struct timeval *tp, struct timezone *tzp);
  89.  
  90.  
  91. /*
  92.  * Operations on timevals.
  93.  *
  94.  * NB: timercmp does not work for >= or <=.
  95.  */
  96. #define timerisset(tvp)         ((tvp).tv_sec || (tvp).tv_usec)
  97.  
  98. #define timercmp(tvp, uvp, cmp) \
  99.         ((tvp).tv_sec cmp (uvp).tv_sec || \
  100.          (tvp).tv_sec = (uvp).tv_sec && (tvp).tv_usec cmp (uvp).tv_usec)
  101. #define timerclear(tvp)         (tvp).tv_sec = (tvp).tv_usec = 0
  102.  
  103.  
  104.  
  105.